﻿#define TRACE
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;

public partial class _Default : System.Web.UI.Page
{
    private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

    protected override void OnLoad(EventArgs e)
    {
        Session["WcfObject"] = WcfObject.GetDemoObject();
        Session["JsObject"] = JsObject.GetDemoObject();
        log.Info("Page loaded.");
        base.OnLoad(e);
    }

    protected void uxAddVar_Click(object sender, EventArgs e)
    {
        TraceSource source = new TraceSource("Default");
        source.TraceEvent(TraceEventType.Warning, 0, "Warning message at " + DateTime.Now.ToString());

        try { ThrowMe(); }
        catch (Exception ex) { log.Error("I almost the whole exception.", ex); }

        Session[uxKey.Text] = uxValue.Text;
    }

    void ThrowMe() { throw new Exception("Exception has occurred!!"); }
}
